.class public Lcom/estrongs/android/taskmanager/tools/j;
.super Landroid/os/AsyncTask;


# instance fields
.field private a:Landroid/app/ProgressDialog;

.field private b:Landroid/app/Activity;


# direct methods
.method public constructor <init>(Landroid/app/Activity;)V
    .locals 0

    invoke-direct {p0}, Landroid/os/AsyncTask;-><init>()V

    iput-object p1, p0, Lcom/estrongs/android/taskmanager/tools/j;->b:Landroid/app/Activity;

    return-void
.end method

.method private a(Landroid/content/ContentResolver;Z)Z
    .locals 5

    const/4 v4, 0x0

    const/4 v0, 0x1

    const/4 v1, 0x0

    iget-object v2, p0, Lcom/estrongs/android/taskmanager/tools/j;->b:Landroid/app/Activity;

    const-string v3, "android.permission.WRITE_SECURE_SETTINGS"

    invoke-virtual {v2, v3}, Landroid/app/Activity;->checkCallingOrSelfPermission(Ljava/lang/String;)I

    move-result v2

    if-nez v2, :cond_1

    const-string v2, "Utils"

    const-string v3, "Using secure settings API to touch ADB setting"

    invoke-static {v2, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    const-string v2, "adb_enabled"

    if-eqz p2, :cond_0

    :goto_0
    invoke-static {p1, v2, v0}, Landroid/provider/Settings$Secure;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

    move-result v0

    :goto_1
    return v0

    :cond_0
    move v0, v1

    goto :goto_0

    :cond_1
    const-string v2, "Utils"

    const-string v3, "Using setprop call to touch ADB setting"

    invoke-static {v2, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    const-string v2, "setprop persist.service.adb.enable %s"

    new-array v3, v0, [Ljava/lang/Object;

    if-eqz p2, :cond_2

    :goto_2
    invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v0

    aput-object v0, v3, v1

    invoke-static {v2, v3}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v0

    invoke-static {v0, v4, v4}, Lcom/estrongs/android/taskmanager/tools/k;->a(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/Integer;)Z

    move-result v0

    goto :goto_1

    :cond_2
    move v0, v1

    goto :goto_2
.end method


# virtual methods
.method protected a(Lcom/estrongs/android/taskmanager/b/b;Ljava/lang/Boolean;)Ljava/lang/Boolean;
    .locals 11

    iget-object v0, p0, Lcom/estrongs/android/taskmanager/tools/j;->b:Landroid/app/Activity;

    const-string v1, "android.permission.CHANGE_COMPONENT_ENABLED_STATE"

    invoke-virtual {v0, v1}, Landroid/app/Activity;->checkCallingOrSelfPermission(Ljava/lang/String;)I

    move-result v0

    if-nez v0, :cond_3

    const-string v0, ""

    const-string v1, "Calling setComponentEnabledState() directly"

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    iget-object v0, p0, Lcom/estrongs/android/taskmanager/tools/j;->b:Landroid/app/Activity;

    invoke-virtual {v0}, Landroid/app/Activity;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v1

    new-instance v2, Landroid/content/ComponentName;

    iget-object v0, p1, Lcom/estrongs/android/taskmanager/b/b;->a:Ljava/lang/String;

    iget-object v3, p1, Lcom/estrongs/android/taskmanager/b/b;->b:Ljava/lang/String;

    invoke-direct {v2, v0, v3}, Landroid/content/ComponentName;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-virtual {p2}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v0

    if-eqz v0, :cond_1

    const/4 v0, 0x1

    :goto_0
    const/4 v3, 0x0

    invoke-virtual {v1, v2, v0, v3}, Landroid/content/pm/PackageManager;->setComponentEnabledSetting(Landroid/content/ComponentName;II)V

    invoke-virtual {v1, v2}, Landroid/content/pm/PackageManager;->getComponentEnabledSetting(Landroid/content/ComponentName;)I

    move-result v0

    iput v0, p1, Lcom/estrongs/android/taskmanager/b/b;->e:I

    invoke-virtual {p1}, Lcom/estrongs/android/taskmanager/b/b;->a()Z

    move-result v0

    invoke-virtual {p2}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v1

    if-ne v0, v1, :cond_2

    const/4 v0, 0x1

    invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v0

    :cond_0
    :goto_1
    return-object v0

    :cond_1
    const/4 v0, 0x2

    goto :goto_0

    :cond_2
    const/4 v0, 0x0

    invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v0

    goto :goto_1

    :cond_3
    const-string v0, ""

    const-string v1, "Changing state by employing root access"

    invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    iget-object v0, p0, Lcom/estrongs/android/taskmanager/tools/j;->b:Landroid/app/Activity;

    invoke-virtual {v0}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v4

    const/4 v1, 0x0

    :try_start_0
    const-string v0, "adb_enabled"

    invoke-static {v4, v0}, Landroid/provider/Settings$Secure;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;)I
    :try_end_0
    .catch Landroid/provider/Settings$SettingNotFoundException; {:try_start_0 .. :try_end_0} :catch_0

    move-result v0

    const/4 v2, 0x1

    if-ne v0, v2, :cond_4

    const/4 v0, 0x1

    :goto_2
    if-nez v0, :cond_d

    const-string v0, ""

    const-string v2, "Switching ADB on for the root call"

    invoke-static {v0, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    const/4 v0, 0x1

    invoke-direct {p0, v4, v0}, Lcom/estrongs/android/taskmanager/tools/j;->a(Landroid/content/ContentResolver;Z)Z

    move-result v0

    if-eqz v0, :cond_d

    const/4 v0, 0x1

    const-wide/16 v1, 0x3e8

    invoke-static {v1, v2}, Lcom/estrongs/android/taskmanager/tools/k;->a(J)V

    move v3, v0

    :goto_3
    const/4 v0, 0x0

    const/4 v1, 0x4

    :try_start_1
    new-array v5, v1, [[Ljava/lang/String;

    const/4 v1, 0x0

    const/4 v2, 0x2

    new-array v2, v2, [Ljava/lang/String;

    const/4 v6, 0x0

    const-string v7, "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH:/system/lib\" pm %s \'%s/%s\'"

    aput-object v7, v2, v6

    aput-object v2, v5, v1

    const/4 v1, 0x1

    const/4 v2, 0x2

    new-array v2, v2, [Ljava/lang/String;

    const/4 v6, 0x0

    const-string v7, "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH:/system/lib\" sh /system/bin/pm %s \'%s/%s\'"

    aput-object v7, v2, v6

    aput-object v2, v5, v1

    const/4 v1, 0x2

    const/4 v2, 0x2

    new-array v2, v2, [Ljava/lang/String;

    const/4 v6, 0x0

    const-string v7, "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH:/system/lib\" app_process /system/bin com.android.commands.pm.Pm %s \'%s/%s\'"

    aput-object v7, v2, v6

    const/4 v6, 0x1

    const-string v7, "CLASSPATH=/system/framework/pm.jar"

    aput-object v7, v2, v6

    aput-object v2, v5, v1

    const/4 v1, 0x3

    const/4 v2, 0x2

    new-array v2, v2, [Ljava/lang/String;

    const/4 v6, 0x0

    const-string v7, "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH:/system/lib\" /system/bin/app_process /system/bin com.android.commands.pm.Pm %s \'%s/%s\'"

    aput-object v7, v2, v6

    const/4 v6, 0x1

    const-string v7, "CLASSPATH=/system/framework/pm.jar"

    aput-object v7, v2, v6

    aput-object v2, v5, v1

    array-length v6, v5

    const/4 v1, 0x0

    move v2, v1

    :goto_4
    if-lt v2, v6, :cond_5

    :goto_5
    if-nez v0, :cond_9

    const/4 v0, 0x0

    invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    move-result-object v0

    if-eqz v3, :cond_0

    const-string v1, "Utils"

    const-string v2, "Switching ADB off again"

    invoke-static {v1, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    const/4 v1, 0x0

    invoke-direct {p0, v4, v1}, Lcom/estrongs/android/taskmanager/tools/j;->a(Landroid/content/ContentResolver;Z)Z

    const-wide/16 v1, 0x1388

    invoke-static {v1, v2}, Lcom/estrongs/android/taskmanager/tools/k;->a(J)V

    goto/16 :goto_1

    :cond_4
    const/4 v0, 0x0

    goto :goto_2

    :catch_0
    move-exception v0

    invoke-virtual {v0}, Landroid/provider/Settings$SettingNotFoundException;->printStackTrace()V

    new-instance v1, Ljava/lang/RuntimeException;

    invoke-direct {v1, v0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/Throwable;)V

    throw v1

    :cond_5
    :try_start_2
    aget-object v7, v5, v2

    const/4 v1, 0x0

    aget-object v8, v7, v1

    const/4 v1, 0x3

    new-array v9, v1, [Ljava/lang/Object;

    const/4 v10, 0x0

    invoke-virtual {p2}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v1

    if-eqz v1, :cond_6

    const-string v1, "enable"

    :goto_6
    aput-object v1, v9, v10

    const/4 v1, 0x1

    iget-object v10, p1, Lcom/estrongs/android/taskmanager/b/b;->a:Ljava/lang/String;

    aput-object v10, v9, v1

    const/4 v1, 0x2

    iget-object v10, p1, Lcom/estrongs/android/taskmanager/b/b;->b:Ljava/lang/String;

    aput-object v10, v9, v1

    invoke-static {v8, v9}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v8

    const/4 v1, 0x1

    aget-object v1, v7, v1

    if-eqz v1, :cond_7

    const/4 v1, 0x1

    new-array v1, v1, [Ljava/lang/String;

    const/4 v9, 0x0

    const/4 v10, 0x1

    aget-object v7, v7, v10

    aput-object v7, v1, v9

    :goto_7
    const/16 v7, 0x61a8

    invoke-static {v7}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v7

    invoke-static {v8, v1, v7}, Lcom/estrongs/android/taskmanager/tools/k;->a(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/Integer;)Z

    move-result v1

    if-eqz v1, :cond_8

    const/4 v0, 0x1

    goto :goto_5

    :cond_6
    const-string v1, "disable"

    goto :goto_6

    :cond_7
    const/4 v1, 0x0

    goto :goto_7

    :cond_8
    add-int/lit8 v1, v2, 0x1

    move v2, v1

    goto :goto_4

    :cond_9
    iget-object v0, p0, Lcom/estrongs/android/taskmanager/tools/j;->b:Landroid/app/Activity;

    invoke-virtual {v0}, Landroid/app/Activity;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v0

    new-instance v1, Landroid/content/ComponentName;

    iget-object v2, p1, Lcom/estrongs/android/taskmanager/b/b;->a:Ljava/lang/String;

    iget-object v5, p1, Lcom/estrongs/android/taskmanager/b/b;->b:Ljava/lang/String;

    invoke-direct {v1, v2, v5}, Landroid/content/ComponentName;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-virtual {v0, v1}, Landroid/content/pm/PackageManager;->getComponentEnabledSetting(Landroid/content/ComponentName;)I

    move-result v0

    iput v0, p1, Lcom/estrongs/android/taskmanager/b/b;->e:I

    invoke-virtual {p1}, Lcom/estrongs/android/taskmanager/b/b;->a()Z

    move-result v0

    invoke-virtual {p2}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v1

    if-ne v0, v1, :cond_a

    const/4 v0, 0x1

    :goto_8
    if-eqz v0, :cond_b

    const-string v1, "Utils"

    const-string v2, "State successfully changed"

    invoke-static {v1, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    :goto_9
    invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    move-result-object v0

    if-eqz v3, :cond_0

    const-string v1, "Utils"

    const-string v2, "Switching ADB off again"

    invoke-static {v1, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    const/4 v1, 0x0

    invoke-direct {p0, v4, v1}, Lcom/estrongs/android/taskmanager/tools/j;->a(Landroid/content/ContentResolver;Z)Z

    const-wide/16 v1, 0x1388

    invoke-static {v1, v2}, Lcom/estrongs/android/taskmanager/tools/k;->a(J)V

    goto/16 :goto_1

    :cond_a
    const/4 v0, 0x0

    goto :goto_8

    :cond_b
    :try_start_3
    const-string v1, "Utils"

    const-string v2, "State change failed"

    invoke-static {v1, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    goto :goto_9

    :catchall_0
    move-exception v0

    if-eqz v3, :cond_c

    const-string v1, "Utils"

    const-string v2, "Switching ADB off again"

    invoke-static {v1, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    const/4 v1, 0x0

    invoke-direct {p0, v4, v1}, Lcom/estrongs/android/taskmanager/tools/j;->a(Landroid/content/ContentResolver;Z)Z

    const-wide/16 v1, 0x1388

    invoke-static {v1, v2}, Lcom/estrongs/android/taskmanager/tools/k;->a(J)V

    :cond_c
    throw v0

    :cond_d
    move v3, v1

    goto/16 :goto_3
.end method

.method protected varargs a([Ljava/lang/Object;)Ljava/lang/Boolean;
    .locals 6

    const/4 v5, 0x1

    const/4 v2, 0x0

    aget-object v0, p1, v2

    check-cast v0, [Lcom/estrongs/android/taskmanager/b/b;

    aget-object v1, p1, v5

    check-cast v1, Ljava/lang/Boolean;

    array-length v3, v0

    :goto_0
    if-lt v2, v3, :cond_0

    invoke-static {v5}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v0

    return-object v0

    :cond_0
    aget-object v4, v0, v2

    invoke-virtual {p0, v4, v1}, Lcom/estrongs/android/taskmanager/tools/j;->a(Lcom/estrongs/android/taskmanager/b/b;Ljava/lang/Boolean;)Ljava/lang/Boolean;

    add-int/lit8 v2, v2, 0x1

    goto :goto_0
.end method

.method protected a(Ljava/lang/Boolean;)V
    .locals 3

    iget-object v0, p0, Lcom/estrongs/android/taskmanager/tools/j;->a:Landroid/app/ProgressDialog;

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/estrongs/android/taskmanager/tools/j;->a:Landroid/app/ProgressDialog;

    invoke-virtual {v0}, Landroid/app/ProgressDialog;->cancel()V

    :cond_0
    invoke-virtual {p1}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v0

    if-nez v0, :cond_1

    new-instance v0, Landroid/app/AlertDialog$Builder;

    iget-object v1, p0, Lcom/estrongs/android/taskmanager/tools/j;->b:Landroid/app/Activity;

    invoke-direct {v0, v1}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V

    const v1, 0x7f07006e

    invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setMessage(I)Landroid/app/AlertDialog$Builder;

    move-result-object v0

    const v1, 0x1080027

    invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setIcon(I)Landroid/app/AlertDialog$Builder;

    move-result-object v0

    const v1, 0x7f0700f2

    invoke-virtual {v0, v1}, Landroid/app/AlertDialog$Builder;->setTitle(I)Landroid/app/AlertDialog$Builder;

    move-result-object v0

    const v1, 0x104000a

    const/4 v2, 0x0

    invoke-virtual {v0, v1, v2}, Landroid/app/AlertDialog$Builder;->setPositiveButton(ILandroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;

    move-result-object v0

    invoke-virtual {v0}, Landroid/app/AlertDialog$Builder;->show()Landroid/app/AlertDialog;

    :cond_1
    return-void
.end method

.method protected varargs synthetic doInBackground([Ljava/lang/Object;)Ljava/lang/Object;
    .locals 1

    check-cast p1, [Ljava/lang/Object;

    invoke-virtual {p0, p1}, Lcom/estrongs/android/taskmanager/tools/j;->a([Ljava/lang/Object;)Ljava/lang/Boolean;

    move-result-object v0

    return-object v0
.end method

.method protected synthetic onPostExecute(Ljava/lang/Object;)V
    .locals 0

    check-cast p1, Ljava/lang/Boolean;

    invoke-virtual {p0, p1}, Lcom/estrongs/android/taskmanager/tools/j;->a(Ljava/lang/Boolean;)V

    return-void
.end method

.method protected onPreExecute()V
    .locals 3

    invoke-super {p0}, Landroid/os/AsyncTask;->onPreExecute()V

    new-instance v0, Landroid/app/ProgressDialog;

    iget-object v1, p0, Lcom/estrongs/android/taskmanager/tools/j;->b:Landroid/app/Activity;

    invoke-direct {v0, v1}, Landroid/app/ProgressDialog;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/estrongs/android/taskmanager/tools/j;->a:Landroid/app/ProgressDialog;

    iget-object v0, p0, Lcom/estrongs/android/taskmanager/tools/j;->a:Landroid/app/ProgressDialog;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Landroid/app/ProgressDialog;->setIndeterminate(Z)V

    iget-object v0, p0, Lcom/estrongs/android/taskmanager/tools/j;->a:Landroid/app/ProgressDialog;

    iget-object v1, p0, Lcom/estrongs/android/taskmanager/tools/j;->b:Landroid/app/Activity;

    const v2, 0x7f0700d4

    invoke-virtual {v1, v2}, Landroid/app/Activity;->getString(I)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/app/ProgressDialog;->setMessage(Ljava/lang/CharSequence;)V

    iget-object v0, p0, Lcom/estrongs/android/taskmanager/tools/j;->a:Landroid/app/ProgressDialog;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Landroid/app/ProgressDialog;->setCancelable(Z)V

    iget-object v0, p0, Lcom/estrongs/android/taskmanager/tools/j;->a:Landroid/app/ProgressDialog;

    invoke-virtual {v0}, Landroid/app/ProgressDialog;->show()V

    return-void
.end method
